{% extends 'base.html' %}
{% from 'bootstrap5/nav.html' import render_breadcrumb_item %}

{% block title %}Dashboard{% endblock %}

{% block navbar %}
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
  <div class="container">
    <a class="navbar-brand" href="{{ url_for('admin.index') }}">
      <img src="{{ url_for('static', filename='favicon.ico') }}" alt="Moments"> Moments Dashboard
    </a>
    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarColor01"
      aria-controls="navbarColor01" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>

    <div class="collapse navbar-collapse" id="navbarColor01">
      <div class="navbar-nav ms-auto">
        {{ render_nav_item('main.index', 'Return Moments') }}
        <div class="dropdown nav-item">
          <a href="#" class="nav-link dropdown-toggle" data-bs-toggle="dropdown" role="button"
            aria-expanded="false">Manage<span class="caret"></span>
          </a>
          <div class="dropdown-menu dropdown-menu-right" role="menu">
            <a class="dropdown-item" href="{{ url_for('admin.manage_photo') }}">Photos</a>
            <a class="dropdown-item" href="{{ url_for('admin.manage_user') }}">Users</a>
            <a class="dropdown-item" href="{{ url_for('admin.manage_tag') }}">Tags</a>
            <a class="dropdown-item" href="{{ url_for('admin.manage_comment') }}">Comments</a>
          </div>
        </div>
        <div class="dropdown nav-item">
          <a href="#" class="nav-link dropdown-toggle" data-bs-toggle="dropdown" role="button" aria-expanded="false">
            <img class="avatar-xs" src="{{ url_for('main.get_avatar', filename=current_user.avatar_s) }}">
            <span class="caret"></span>
          </a>
          <div class="dropdown-menu dropdown-menu-end" role="menu">
            <h6 class="dropdown-header">Logged in as {{ current_user.username }}</h6>
            <a class="dropdown-item" href="{{ url_for('user.index', username=current_user.username) }}">
              {{ render_icon('person-fill') }} My Home
            </a>
            <div class="dropdown-divider"></div>
            <a class="dropdown-item" href="{{ url_for('user.edit_profile') }}">
              {{ render_icon('gear-fill') }} Settings
            </a>
            <a class="dropdown-item" href="{{ url_for('auth.logout') }}">
              {{ render_icon('power') }} Logout
            </a>
          </div>
        </div>
      </div>
    </div>
  </div>
</nav>
{% endblock %}

{% block content %}
<nav aria-label="breadcrumb">
  <ol class="breadcrumb">
    {{ render_breadcrumb_item('admin.index', 'Dashboard Home') }}
  </ol>
</nav>
<div class="row">
  <div class="col-md-6">
    <div class="card border-primary mb-3">
      <div class="card-header">{{ render_icon('image') }} Photos</div>
      <div class="card-body">
        <h4 class="card-title">Total: {{ photo_count|default('0') }}</h4>
        <p class="card-text">Reported: {{ reported_photos_count|default('0') }}</p>
        <a class="btn btn-primary text-white" href="{{ url_for('.manage_photo') }}">Manage</a>
      </div>
    </div>
  </div>
  <div class="col-md-6">
    <div class="card border-secondary mb-3">
      <div class="card-header">{{ render_icon('people-fill') }} Users</div>
      <div class="card-body">
        <h4 class="card-title">Total: {{ user_count|default('0') }}</h4>
        <p class="card-text">Locked: {{ locked_user_count|default('0') }}
          Blocked: {{ blocked_user_count|default('0') }}</p>
        <a class="btn btn-primary text-white" href="{{ url_for('.manage_user') }}">Manage</a>
        <a class="btn btn-secondary text-white" href="{{ url_for('.manage_user', filter='locked') }}">View
          Locked</a>
        <a class="btn btn-secondary text-white" href="{{ url_for('.manage_user', filter='blocked') }}">View
          Blocked</a>
      </div>
    </div>
  </div>
</div>
<div class="row">
  <div class="col-md-6">
    <div class="card border-danger mb-3">
      <div class="card-header">{{ render_icon('chat-left-fill') }} Comments</div>
      <div class="card-body">
        <h4 class="card-title">Total: {{ comment_count|default('0') }}</h4>
        <p class="card-text">Reported: {{ reported_comments_count|default('0') }}</p>
        <a class="btn btn-primary text-white" href="{{ url_for('.manage_comment') }}">Manage</a>
      </div>
    </div>
  </div>
  <div class="col-md-6">
    <div class="card border-success mb-3">
      <div class="card-header">{{ render_icon('tag-fill') }} Tags</div>
      <div class="card-body">
        <h4 class="card-title">Total: {{ tag_count|default('0') }}</h4>
        <p class="card-text">&nbsp;</p>
        <a class="btn btn-primary text-white" href="{{ url_for('.manage_tag') }}">Manage</a>
      </div>
    </div>
  </div>
</div>
{% endblock %}
